####
# Find clang libraries
####
if(NOT LIBCLANG_LIBRARIES)
	find_library(LIBCLANG_LIBRARY_ANALYSIS NAMES clangAnalysis libclangAnalysis PATHS ${LLVM_LIBS_PATH})
	find_library(LIBCLANG_LIBRARY_AST NAMES clangAST libclangAST PATHS ${LLVM_LIBS_PATH})
	find_library(LIBCLANG_LIBRARY_BASIC NAMES clangBasic libclangBasic PATHS ${LLVM_LIBS_PATH})
	find_library(LIBCLANG_LIBRARY_CODEGEN NAMES clangCodeGen libclangCodeGen PATHS ${LLVM_LIBS_PATH})
	find_library(LIBCLANG_LIBRARY_DRIVER NAMES clangDriver libclangDriver PATHS ${LLVM_LIBS_PATH})
	find_library(LIBCLANG_LIBRARY_EDIT NAMES clangEdit libclangEdit PATHS ${LLVM_LIBS_PATH})
	find_library(LIBCLANG_LIBRARY_FRONTEND NAMES clangFrontend libclangFrontend PATHS ${LLVM_LIBS_PATH})
	find_library(LIBCLANG_LIBRARY_LEX NAMES clangLex libclangLex PATHS ${LLVM_LIBS_PATH})
	find_library(LIBCLANG_LIBRARY_PARSE NAMES clangParse libclangParse PATHS ${LLVM_LIBS_PATH})
	find_library(LIBCLANG_LIBRARY_SEMA NAMES clangSema libclangSema PATHS ${LLVM_LIBS_PATH})
	find_library(LIBCLANG_LIBRARY_SERIALIZATION NAMES clangSerialization libclangSerialization PATHS ${LLVM_LIBS_PATH})
	
	if(LIBCLANG_LIBRARY_ANALYSIS AND LIBCLANG_LIBRARY_AST AND LIBCLANG_LIBRARY_BASIC AND LIBCLANG_LIBRARY_CODEGEN AND LIBCLANG_LIBRARY_DRIVER AND LIBCLANG_LIBRARY_EDIT AND LIBCLANG_LIBRARY_FRONTEND AND LIBCLANG_LIBRARY_LEX AND LIBCLANG_LIBRARY_PARSE AND LIBCLANG_LIBRARY_SEMA AND LIBCLANG_LIBRARY_SERIALIZATION)
		set(LIBCLANG_LIBRARIES ${LIBCLANG_LIBRARY_ANALYSIS} ${LIBCLANG_LIBRARY_AST} ${LIBCLANG_LIBRARY_BASIC} ${LIBCLANG_LIBRARY_CODEGEN} ${LIBCLANG_LIBRARY_DRIVER} ${LIBCLANG_LIBRARY_EDIT} ${LIBCLANG_LIBRARY_FRONTEND} ${LIBCLANG_LIBRARY_LEX} ${LIBCLANG_LIBRARY_PARSE} ${LIBCLANG_LIBRARY_SEMA} ${LIBCLANG_LIBRARY_SERIALIZATION})
	else()
		# Try shared libclang-cpp.so
		find_library(LIBCLANG_LIBRARIES NAMES clang-cpp libclang-cpp PATHS ${LLVM_LIBS_PATH})
	endif()
endif()
if(NOT LIBCLANG_INCLUDE_PATH)
	find_path(LIBCLANG_INCLUDE_PATH clang-c/Index.h PATHS ${LLVM_INCLUDE_PATH})
endif()
if(LIBCLANG_LIBRARIES AND LIBCLANG_INCLUDE_PATH)
	message(STATUS "Using clang libraries: ${LIBCLANG_LIBRARIES}")
	message(STATUS "Using clang headers: ${LIBCLANG_INCLUDE_PATH}")
	set(VC4C_ENABLE_LIBCLANG ON)
else()
	message(WARNING "Clang library precompilation enabled, but no clang libraries were found")
	set(VC4C_ENABLE_LIBCLANG OFF)
endif()
